package com.wnx.action;

import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.wnx.db.ReviewDao;
import com.wnx.entity.Review;

public class ReviewFenYeAction extends ActionSupport {
	private String FenYe;
	
	public String getFenYe() {
		return FenYe;
	}
	public void setFenYe(String fenYe) {
		FenYe = fenYe;
	}
	private Map<String,List<Review>> dataMap = new Hashtable<>();
	
	public Map<String, List<Review>> getDataMap() {
		return dataMap;
	}
	public String execute() throws Exception{
		
		HttpServletRequest request = ServletActionContext.getRequest();
		int id = Integer.parseInt(request.getParameter("id"));
		if(this.FenYe.equals("five")){
		ReviewDao rd = new ReviewDao();
		Review re = new Review();
		List<Review> review  = rd.getReviewFive(id);
		dataMap.put("review", review);
		
		return SUCCESS;
		}else if(this.FenYe.equals("all")){
			ReviewDao rd = new ReviewDao();
			Review re = new Review();
			List<Review> review  = rd.getReviewAll(id);
			dataMap.put("review", review);
			return SUCCESS;
		}
		else{
			return ERROR;
		}
	}
}
